/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.txweb.view;

import com.jspx.txweb.annotation.HttpMethod;
import com.jspx.txweb.annotation.Safety;
import com.jspx.txweb.dao.TagsDAO;
import com.jspx.txweb.env.TXWebIoc;
import com.jspx.txweb.support.ActionSupport;
import com.jspx.sioc.annotation.Ref;
import com.jspx.boot.environment.Environment;
import com.jspx.txweb.table.TagWord;
import com.jspx.utils.StringUtil;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: chenYuan
 * Date: 2009-1-12
 * Time: 16:32:07
 *
 */
@HttpMethod(caption="关键字")
public class TagsView extends ActionSupport
{
    private int currentPage = 1;
    private int count = 12;
    private String word = StringUtil.empty;
    
    public TagsView()
    {

    }

    private TagsDAO tagsDAO;
    @Ref(name = TXWebIoc.tagsDAO)
    public void setTagsDAO(TagsDAO tagsDAO)
    {
        this.tagsDAO = tagsDAO;
    }

    public String getWord() {
        return word;
    }

    @Safety
    public void setWord(String word) {
        this.word = word;
    }

    public int getCurrentPage()
    {
        return currentPage;
    }

    @Safety
    public void setCurrentPage(int currentPage)
    {
        this.currentPage = currentPage;
    }

    public int getCount()
    {
        if (count <= 0)
        {
            count = config.getInt(Environment.rowCount, 18);
        }
        return count;
    }

    @Safety
    public void setCount(int count)
    {
        this.count = count;
    }
    
    public  List<TagWord> getList() throws Exception
    {
        return tagsDAO.getList(currentPage,count);
    }

    public  List<TagWord> getTagWordChild() throws Exception
    {
        return tagsDAO.getTagWordChild(word, currentPage, count);
    }
}